package com.wish233.wiliwilivideo.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author WHH
 * @description 针对表【like_counts(点赞数量表)】的数据库操作Mapper
 * @createDate 2025-03-18 14:35:29
 * @Entity generator.domain.LikeCounts
 */
public interface LikeCountsMapper {

    @Insert("INSERT INTO like_counts (biz_id, message_id, num) " +
            "VALUES (#{bizId}, #{messageId}, #{delta}) " +
            "ON DUPLICATE KEY UPDATE num = num + #{delta}")
    int upsertLikeCount(@Param("bizId") Integer bizId, @Param("messageId") Long messageId, @Param("delta") Long delta);

    @Select("SELECT num FROM like_counts WHERE biz_id = #{bizId} AND message_id = #{messageId}")
    Long queryLikeCount(@Param("bizId") Integer bizId, @Param("messageId") Long messageId);
}




